﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Home.Master" AutoEventWireup="true"
    CodeBehind="LandsCompensation.aspx.cs" Inherits="Giaiphongmatbang.WebForm1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="Style/duan.css" rel="stylesheet" type="text/css" />
    <link href="Style/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="/Scripts/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function showdialog() {
            $('.dialogForm').dialog({
                modal: true,
                autoOpen: false,
                width: 520,
                close: function (event, ui) {
                if (event.originalEvent && $(event.originalEvent.target).closest(".ui-dialog-titlebar-close").length) {
                    $("body").append("do some  stuff<br>");
                }
            }
            });
            $(".dialogForm").parent().appendTo($("form:first"))
            $('.dialogForm').dialog('open');
            return false;
        }

        $(document).ready(function () {
            $('.dialogForm').dialog({
                modal: true,
                autoOpen: false,
                width: 520,
                close: function (event, ui) {
                if (event.originalEvent && $(event.originalEvent.target).closest(".ui-dialog-titlebar-close").length) {
                    $("body").append("do some  stuff<br>");
                }
            }
            });
        });

        function addland() {
            $('#<%=txtLandName.ClientID%>').val('');
            $('#<%=hdfmodenew.ClientID %>').val('true');
            $('#<%=txtDescriptions.ClientID%>').val('');

            $(".dialogForm").parent().appendTo($("form:first"))
            $('.dialogForm').dialog('open');
            return false;
        }

        function editland(id, name, support, des) {
            $('#<%=txtLandName.ClientID%>').val(name);
            $('#<%=txtDescriptions.ClientID%>').val(des);
            $('#<%=hdfmodenew.ClientID %>').val('false');
            $('#<%=hdf.ClientID %>').val(id);
            if (support == 'True') {
                $('#<%=chk_Support.ClientID %>').attr('checked', true);
            }
            else {
                $('#<%=chk_Support.ClientID %>').attr('checked', false);
            }

            $(".dialogForm").parent().appendTo($("form:first"))
            $('.dialogForm').dialog('open');
            return false;
        }

        function closeform() {
            $('.dialogForm').dialog("close");
            return false;
        }

        function keypress(e) {
            var keypressed = null;
            if (window.event) {
                keypressed = window.event.keyCode;
            }
            else {
                keypressed = e.which;
            }

            if (keypressed < 48 || keypressed > 57) {
                if (keypressed == 8 || keypressed == 127 || keypressed == null || keypressed == 0 || keypressed == 9 || keypressed == 13 || keypressed == 46) {
                    return;
                }

                return false;
            }
        }

        function check() {
            if ($('#<%=txtLandName.ClientID %>').val() == '' || $('#<%=txtLandName.ClientID %>').val() == null) {
                return false;
            }
            else {
                return confirm('Xác nhận hành động?');
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <%--    <asp:UpdatePanel ID="uppn" runat="server">
        <ContentTemplate>--%>
    <div class="box-title">
        Bảng giá các loại đất
        <div class="nr" style="margin-top: 3px">
            <asp:ImageButton ID="ibtnAdd" runat="server" ImageUrl="~/Images/add-button.jpg" OnClientClick="return addland()" ToolTip="Thêm mới loại đất" />
        </div>
    </div>
    <div class="table">
        <asp:GridView ID="grv_ListLand" runat="server" AutoGenerateColumns="false" 
            Width="100%" BorderWidth="0" GridLines="None" 
            onrowcommand="grv_ListLand_RowCommand" 
            onrowdatabound="grv_ListLand_RowDataBound">
            <Columns>
                <asp:TemplateField HeaderText="TT" ItemStyle-Width="45px">
                    <ItemTemplate>
                        <%# (Container.DataItemIndex + 1) %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="LandName" HeaderText="Loại đất" ItemStyle-Width="50%" />
                <asp:TemplateField HeaderText="Hỗ trợ" ItemStyle-Width="100px">
                    <ItemTemplate>
                            <%#Eval("isSupport").ToString()=="True"?"Hỗ trợ":"Không" %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Description" HeaderText="Mô tả" />
                <asp:TemplateField HeaderText="Thao tác" ItemStyle-Width="100px">
                    <ItemTemplate>
                        <a onclick="return editland(<%#Eval("LandID") %>, '<%#Eval("LandName") %>', '<%#Eval("isSupport") %>', '<%#Eval("Description") %>')">
                            <img src="Images/pen.png" alt="Xóa" title="Xóa" />
                        </a>
                        <asp:ImageButton ID="ibtnDelete" runat="server" ImageUrl="~/Images/delete.png" CommandArgument='<%#Eval("LandID") %>' CommandName="ibtnDelete" OnClientClick="return confirm('Bạn chắc chắn xóa?');" />
                    </ItemTemplate>
                </asp:TemplateField>

            </Columns>
        </asp:GridView>
    </div>
    <div style="display: none">
        <asp:HiddenField ID="hdf" runat="server" Value="" />
        <asp:HiddenField ID="hdfmodenew" runat="server" />
    </div>
    <%--        </ContentTemplate>
    </asp:UpdatePanel>--%>
    <div class="dialogForm" title="Cập nhật bảng giá đất" style="display: none">
        <table cellpadding="5" cellspacing="5">
            <tr>
                <td>
                    Tên loại đất
                </td>
                <td style="width:400px;">
                    <asp:TextBox ID="txtLandName" runat="server" Style="width: 90%" AutoComplete="Off" CssClass="field" /><i style="color:Red">(*)</i>
                </td>
            </tr>
            <tr>
                <td>
                    Hỗ trợ:
                </td>
                <td>
                    <asp:CheckBox ID="chk_Support" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    Mô tả
                </td>
                <td>
                    <asp:TextBox ID="txtDescriptions" runat="server" Style="width: 90%" AutoComplete="Off" CssClass="field" />
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    <asp:Button ID="btnAddLand" OnClientClick="return check()"
                        CssClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
                        runat="server" Text="&nbsp;OK&nbsp;" OnClick="btnAddLand_Click"/>
                    <input type="button" id="btnCancel" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" value="Cancel" onclick="return closeform();"/>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
